package utils;

import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by 冷丶 on 2017/11/19.
 */
public class ControllerUtils {
    public static List<Class> getAllClass(String packName) throws ClassNotFoundException {
        List<Class> list = new ArrayList<Class>();
        String packPath = packName.replace(".","/");
        URL url =Thread.currentThread().getContextClassLoader().getResource(packPath);
        String filePath = url.getPath();
        File file = new File(filePath);
        File[] files = file.listFiles();
        for (File file1: files){
            String fileName = file1.getName();
            String className = packName+"."+fileName.substring(0,fileName.length()-6);
            Class c = Class.forName(className);
            list.add(c);
        }
        return list;
    }

}
